function vel=magnitudeVelocity(y,C, mu)

%File computes magnitude of velocity for a given state (x,C)

%the distances
r1=sqrt((y(1,1)+mu)^2+(y(2,1))^2+(y(3,1))^2);
r2=sqrt((y(1,1)-(1-mu))^2+(y(2,1))^2+(y(3,1))^2);

%Compute the potential
Potential=(1/2)*(y(1,1)^2+y(2,1)^2)+(1-mu)/r1+mu/r2;

%Compute Magnitude of Velocity
vel=sqrt(2*Potential-C);
